﻿<cfsilent>
	<cfscript>
		event.setArg("pageTitle", "教学运行管理 - 考试安排 - 期中考试安排");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		courseId = event.getArg("CID");
		termId = event.getArg("TID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		termDateStart = event.getArg("DateStart");
		currentTab = event.getArg("TabID", "labArrange");
		
		sql = "SELECT 
					 t_course.course_name, 
					 t_institute.institute_name, 
					 t_course.period, 
					 t_course.period_theory, 
					 t_course.course_credit, 
					 t_course.cid, 
					 t_institute.institute_id      
				FROM 
					 t_course 
					 INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
				WHERE 
					 t_course.cid = :courseId ";
		
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		
		rs_course = queryObj.execute( sql=sql ).getResult();
	
		sql = "SELECT campus_id, campus_name FROM t_campus ORDER BY campus_id ";
		
		queryObj = new query( datasource=application.dnsSlave );
		rs_campus = queryObj.execute( sql=sql ).getResult();
		
		passArgs = structNew();
		targetArgs = structNew();
		passDelArgs = structNew();
		/* 学院已安排的考试任务 */
		
												
		sql = "SELECT 
				  t_course.course_name, 
				  t_examtask.exidx, 
				  t_examtask.wid, 
				  t_campus.campus_name,
				  t_examtask.wdidx, 
				  t_examtask.cellidx, 
				  t_examtask.task_exid 
			  FROM 
				  t_examtask 
				  INNER JOIN t_course ON t_course.cid = t_examtask.cid 
				  INNER JOIN t_campus ON t_campus.campus_id = t_examtask.campus_id 
			  WHERE 
				  t_examtask.term_id = :termId 
				  AND 
				  t_examtask.exam_type = 'M' 
				  AND 
				  t_course.cid = :courseId 
			  ORDER BY 
				  t_course.course_name, t_examtask.exidx ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		
		rs_courseDone = queryObj.execute( sql=sql ).getResult();
		
		taskRestoreArray =[];
		
		sql = "SELECT 
					 a.tsk_id, 
					 a.cidx, 
					 t_campus.campus_name, 
					 t_teacher.tch_name, 
					 a.task_week, 
					 a.task_chooesd, 
					 a.task_classes taskClasses, 
					 t_campus.campus_id, 
					 t_course.course_name 
				FROM 
					 t_task a 
					 INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
					 INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
					 INNER JOIN t_course ON t_course.cid = a.cid 
				WHERE 
					 a.term_id = :termId 
					 AND 
					 t_course.cid = :courseId 
					 AND 
					 EXISTS(
						 SELECT 1 FROM t_exammidplan b 
						 WHERE b.task_id = a.tsk_id AND b.is_arrange = '0'
					 )
				ORDER BY 
					 t_campus.campus_name, t_teacher.tch_name, a.cidx ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		
		rs_taskProgram = queryObj.execute( sql=sql ).getResult();
												
	
														
		sql = "SELECT 
					 a.tsk_id, 
					 a.cidx, 
					 t_campus.campus_name, 
					 t_teacher.tch_name, 
					 a.task_week, 
					 a.task_chooesd, 
					 a.task_classes taskClasses, 
					 t_campus.campus_id, 
					 t_course.course_name 
				FROM 
					 t_task a 
					 INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
					 INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
					 INNER JOIN t_course ON t_course.cid = a.cid 
				WHERE 
					 a.term_id = :termId 
					 AND 
					 t_course.cid = :courseId 
					 AND 
					 EXISTS(
						 SELECT 1 FROM t_exammidplan b 
						 WHERE b.task_id = a.tsk_id AND b.is_arrange = 'N'
					 )
				ORDER BY 
					 t_campus.campus_name, t_teacher.tch_name, a.cidx ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		
		rs_taskProgramRestore = queryObj.execute( sql=sql ).getResult();
		
	
		sql = "SELECT 
					 a.tsk_id, 
					 a.cidx, 
					 t_campus.campus_name, 
					 t_teacher.tch_name, 
					 a.task_week, 
					 a.task_chooesd, 
					 '-' taskClasses, 
					 t_campus.campus_id, 
					 t_course.course_name 
				FROM 
					 t_common_task a 
					 INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
					 INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
					 INNER JOIN t_course ON t_course.cid = a.cid 
				WHERE 
					 a.term_id = :termId 
					 AND 
					 t_course.cid = :courseId 
					 AND 
					 EXISTS(
						 SELECT 1 FROM t_exammidplan b 
						 WHERE b.task_id = a.tsk_id AND b.is_arrange = '0'
					 )
				ORDER BY 
					 t_campus.campus_name, t_teacher.tch_name, a.cidx ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		
		rs_taskCommon = queryObj.execute( sql=sql ).getResult();
	
														
		sql = "SELECT 
					 a.tsk_id, 
					 a.cidx, 
					 t_campus.campus_name, 
					 t_teacher.tch_name, 
					 a.task_week, 
					 a.task_chooesd, 
					 '-' taskClasses, 
					 t_campus.campus_id, 
					 t_course.course_name 
				FROM 
					 t_common_task a 
					 INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
					 INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
					 INNER JOIN t_course ON t_course.cid = a.cid 
				WHERE 
					 a.term_id = :termId 
					 AND 
					 t_course.cid = :courseId 
					 AND 
					 EXISTS(
						 SELECT 1 FROM t_exammidplan b 
						 WHERE b.task_id = a.tsk_id AND b.is_arrange = 'N'
					 )
				ORDER BY 
					 t_campus.campus_name, t_teacher.tch_name, a.cidx ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		
		rs_taskCommonRestore = queryObj.execute( sql=sql ).getResult();
		
		
												
		sql = "SELECT 
					 a.tsk_id, 
					 a.cidx, 
					 t_campus.campus_name, 
					 t_teacher.tch_name, 
					 a.task_week, 
					 a.task_chooesd, 
					 '-' taskClasses, 
					 t_campus.campus_id, 
					 t_course.course_name 
				FROM 
					 t_reopen_task a 
					 INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
					 INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
					 INNER JOIN t_course ON t_course.cid = a.cid 
				WHERE 
					 a.term_id = :termId 
					 AND 
					 t_course.cid = :courseId 
					 AND 
					 EXISTS(
						 SELECT 1 FROM t_exammidplan b 
						 WHERE b.task_id = a.tsk_id AND b.is_arrange = '0'
					 )
				ORDER BY 
					 t_campus.campus_name, t_teacher.tch_name, a.cidx ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		
		rs_taskOpen = queryObj.execute( sql=sql ).getResult();
		
	
														
		sql = "SELECT 
					 a.tsk_id, 
					 a.cidx, 
					 t_campus.campus_name, 
					 t_teacher.tch_name, 
					 a.task_week, 
					 a.task_chooesd, 
					 '-' taskClasses, 
					 t_campus.campus_id, 
					 t_course.course_name 
				FROM 
					 t_reopen_task a 
					 INNER JOIN t_campus ON t_campus.campus_id = a.campus_id 
					 INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
					 INNER JOIN t_course ON t_course.cid = a.cid 
				WHERE 
					 a.term_id = :termId 
					 AND 
					 t_course.cid = :courseId 
					 AND 
					 EXISTS(
						 SELECT 1 FROM t_exammidplan b 
						 WHERE b.task_id = a.tsk_id AND b.is_arrange = 'N'
					 )
				ORDER BY 
					 t_campus.campus_name, t_teacher.tch_name, a.cidx ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		
		rs_taskOpenRestore = queryObj.execute( sql=sql ).getResult();
		
	taskIds = "";
	taskStartArray = [];
	taskEndArray = [];
	campusQuery = queryNew("CampusID", "VarChar");
	for ( a=1; a LTE rs_taskProgram.recordCount; a++) {
			/* 设置默认的教学班考试合班 */
			taskIds = listAppend(taskIds, rs_taskProgram["tsk_id"][a], "|");
			
			/* 计算最晚和最早的考试结束周次 */
			taskEnd = 1 * listLast(rs_taskProgram["task_week"][a], "-");
			if ( not arrayFind(taskEndArray, taskEnd) ) {
				arrayAppend(taskEndArray, taskEnd);
			}
			taskStart =1 * listFirst(rs_taskProgram["task_week"][a], "-");
			if(not arrayFind(taskStartArray, taskStart)){
				arrayAppend(taskStartArray, taskStart);
			}
			/* 生成校区查询 */
			queryAddRow(campusQuery, 1);
			querySetCell(campusQuery, "CampusID", rs_taskProgram["campus_id"][a]);
		}
	for ( b=1; b LTE rs_taskCommon.recordCount; b++) {
			/* 设置默认的教学班考试合班 */
			taskIds = listAppend(taskIds, rs_taskCommon["tsk_id"][b], "|");
			
			/* 计算最晚和最早的考试结束周次 */
			taskEnd = 1 * listLast(rs_taskCommon["task_week"][b], "-");
			if ( not arrayFind(taskEndArray, taskEnd) ) {
				arrayAppend(taskEndArray, taskEnd);
			}
			taskStart =1 * listFirst(rs_taskCommon["task_week"][b], "-");
			if(not arrayFind(taskStartArray, taskStart)){
				arrayAppend(taskStartArray, taskStart);
			}
			/* 生成校区查询 */
			queryAddRow(campusQuery, 1);
			querySetCell(campusQuery, "CampusID", rs_taskCommon["campus_id"][b]);
		}
	for ( c=1; c LTE rs_taskOpen.recordCount; c++) {
			/* 设置默认的教学班考试合班 */
			taskIds = listAppend(taskIds, rs_taskOpen["tsk_id"][c], "|");
			
			/* 计算最晚和最早的考试结束周次 */
			taskEnd = 1 * listLast(rs_taskOpen["task_week"][c], "-");
			if ( not arrayFind(taskEndArray, taskEnd) ) {
				arrayAppend(taskEndArray, taskEnd);
			}
			taskStart =1 * listFirst(rs_taskOpen["task_week"][c], "-");
			if(not arrayFind(taskStartArray, taskStart)){
				arrayAppend(taskStartArray, taskStart);
			}
			/* 生成校区查询 */
			queryAddRow(campusQuery, 1);
			querySetCell(campusQuery, "CampusID", rs_taskOpen["campus_id"][c]);
		}
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('examMidArrange')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">期中考试安排 </span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 campus"></i>期中考试安排
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix">
			
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labArrange">class="active"</cfif> id="labArrange" tabTarget="Arrange">创建考试任务</span>
						<cfif rs_taskProgramRestore.recordCount or rs_taskCommonRestore.recordCount or rs_taskOpenRestore.recordCount>
							<span <cfif currentTab eq "labNoTaskArrange">class="active"</cfif> id="labNoTaskArrange" tabTarget="NoTaskArrange">不安排考试任务</span>
						</cfif>
						<cfif rs_courseDone.recordCount>
							<span <cfif currentTab eq "labDoneArrange">class="active"</cfif> id="labDoneArrange" tabTarget="DoneArrange">考试周次及分组</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				<div id="Arrange" class="tabContent">
					<div class="noticeBlock">
						<div class="operation">
						</div>
						<h3>《<cfoutput>#rs_course.course_name#</cfoutput>》 任课单位: <cfoutput>#rs_course.institute_name#</cfoutput></h3>
						<p><span class="img icon16x16 message"></span>总学时 <em><cfoutput>#rs_course.period#</cfoutput></em>, 其中理论学时 <em><cfoutput>#rs_course.period_theory#</cfoutput></em>. 课程总学分:<em><cfoutput>#numberFormat(rs_course.course_credit, '_.00')#</cfoutput></em> 在<em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期</p>
					</div>	
					<cfif rs_taskProgram.recordCount or rs_taskCommon.recordCount or rs_taskOpen.recordCount>
					<div id="formBox" class="hidden_elem">
						<form id="formCreate" class="formWrapper" method="post" action="<cfoutput>#buildURL('midExamTaskCreateDo')#</cfoutput>">
							<input type="hidden" name="CourseID" value="<cfoutput>#rs_course.cid#</cfoutput>" />
							<input type="hidden" name="TermID" value="<cfoutput>#termId#</cfoutput>" />
							<input type="hidden" id="TaskClassIDs" name="TaskClassIDs" value="<cfoutput>#taskIds#</cfoutput>" />
								
							<!--- PASSED ARGS --->
							<input type="hidden" name="InstituteID" value="<cfoutput>#rs_course.institute_id#</cfoutput>" />
							<input type="hidden" name="TabID" value="labArrange" />
							<div class="label">
								<span class="req">*</span><b>已选教学任务</b>
								<div id="TaskClassNames" class="secondRow"></div>
							</div>
							<!--- 设置最适合的校区 --->
								<cfquery name="campusSuggest" dbtype="query">
									SELECT CampusID, COUNT(*) TaskCount
									FROM campusQuery
									GROUP BY CampusID
									ORDER BY TaskCount DESC
								</cfquery>
								
								<div class="label">
									<b>考试校区</b>
									<select name="CampusID" id="CampusID">
                                        <cfloop query="rs_campus" >
											<option <cfif campusSuggest.CampusID eq rs_campus.campus_id>selected="selected"</cfif> value="<cfoutput>#rs_campus.campus_id#</cfoutput>"><cfoutput>#rs_campus.campus_name#</cfoutput></option>
										</cfloop>
									</select>
								</div>
								<cfset arraySort(taskEndArray, "numeric", "asc") />
								<cfset arraySort(taskStartArray, "numeric", "asc") />
                                <!--- /* 该门课程授课 最早什么时候结束 */ --->
								<cfset taskEndMin = taskEndArray[1] />
								<!--- /* 该门课程授课 最晚什么时候结束 */ --->
								<cfset taskEndMax = taskEndArray[arrayLen(taskEndArray)] />
                                <!--- /* 该门课程授课 最早什么时候开始 */ --->
								<cfset taskStartMin = taskStartArray[1] />
								<!--- /* 该门课程授课 最晚什么时候开始 */ --->
								<cfset taskStartMax = taskStartArray[arrayLen(taskEndArray)] />
								<div class="label">
									<b>考试周次</b>
									<select name="WID" id="WID">
										<cfloop from="#taskStartMin#" to="#taskEndMax#" index="wid">
											<option <cfif taskStartMin+2 eq wid>selected="selected"</cfif> value="<cfoutput>#numberFormat(wid, '0_')#</cfoutput>">第<cfoutput>#wid#</cfoutput>周</option>
										</cfloop>
									</select>
								</div>
							<div class="lable">
								<input class="button" type="submit" value="建立考试任务" />
								<input id="formReset" class="button1" type="button" value="返回" />
							</div>
						</form>
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {
								
									$("#formReset").click(function(){
									
										$("#taskBox").removeClass("hidden_elem");
										$("#formBox").addClass("hidden_elem");
									});
									
								});
								// -->
								//]]>
							</script>
						
					</div>
					<div id="taskBox">
							<cfset row = 0 />
							<cfset isArrangeClass = 0 />
							<div class="uiOperationBox">
								<a id="opCreate" href="javascript:void(0);" class="uiOperationButton"><i class="btn execute"></i><span class="btnText">创建考试安排</span></a>
							</div>
							<table id="taskList" class="UIEditable">
								<thead>
									<tr>
										<td width="18"></td>
										<td width="50">课序号</td>
										<td width="70">课程类别</td>
										<td class="hidden_elem">教学班</td>
										<td width="60">上课校区</td>
										<td width="50">上课周次</td>
										<td width="50">选课人数</td>
										<td width="110">任课教师</td>
										<td>行政班</td>
										<td width="18"></td>
									</tr>
								</thead>
								<tbody>
									<cfif rs_taskProgram.recordCount>
                                        <cfloop query="rs_taskProgram"  >
										<cfset row++ />
										<cfset isArrangeClass ++ />
										<cfset structInsert(passArgs, "TaskID", rs_taskProgram.tsk_id, true) />
										<cfset structInsert(passArgs, "CourseID", courseId, true) />
										<cfset structInsert(passArgs, "TermID", termId, true) />
										<tr class="editRows" rowid="<cfoutput>#rs_taskProgram.tsk_id#</cfoutput>">
											<td><a rowid="<cfoutput>#rs_taskProgram.tsk_id#</cfoutput>" usage="ForTask" class="stat yes"></a></td>
											<td class="index"><cfoutput>#rs_taskProgram.cidx#</cfoutput></td>
											<td>计划课程</td>
											<td class="hidden_elem"><span usage="ForTaskClassNames"><cfoutput>#rs_taskProgram.course_name#</cfoutput>-<cfoutput>#rs_taskProgram.tch_name#</cfoutput>-<cfoutput>#rs_taskProgram.cidx#</cfoutput></span></td>
											<td><cfoutput>#rs_taskProgram.campus_name#</cfoutput></td>
											<td><span class="numeric"><cfoutput>#rs_taskProgram.task_week#</cfoutput></span></td>
										    <td><span class="numeric"><cfoutput>#rs_taskProgram.task_chooesd#</cfoutput></span></td>
											<td><cfoutput>#rs_taskProgram.tch_name#</cfoutput></td>
											<td><cfif rs_taskProgram.taskClasses eq "-">全校<cfelse><cfoutput>#rs_taskProgram.taskClasses#</cfoutput></cfif></td>
											<td><a title="该教学班不考试" href="<cfoutput>#buildURL('examMidCourseTaskRemoveDo', passArgs)#</cfoutput>" class="stat remove"></a></td>
										</tr>
										</cfloop>
									</cfif>
									<cfif rs_taskCommon.recordCount>
                                        <cfloop query="rs_taskCommon"  >
										<cfset row++ />
										<cfset isArrangeClass ++ />
										<cfset structInsert(passArgs, "TaskID", rs_taskCommon.tsk_id, true) />
										<cfset structInsert(passArgs, "CourseID", courseId, true) />
										<cfset structInsert(passArgs, "TermID", termId, true) />
										<tr class="editRows" rowid="<cfoutput>#rs_taskCommon.tsk_id#</cfoutput>">
											<td><a rowid="<cfoutput>#rs_taskCommon.tsk_id#</cfoutput>" usage="ForTask" class="stat yes"></a></td>
											<td class="index"><cfoutput>#rs_taskCommon.cidx#</cfoutput></td>
											<td>全校通选</td>
											<td class="hidden_elem"><span usage="ForTaskClassNames"><cfoutput>#rs_taskCommon.course_name#</cfoutput>-<cfoutput>#rs_taskCommon.tch_name#</cfoutput>-<cfoutput>#rs_taskCommon.cidx#</cfoutput></span></td>
											<td><cfoutput>#rs_taskCommon.campus_name#</cfoutput></td>
											<td><span class="numeric"><cfoutput>#rs_taskCommon.task_week#</cfoutput></span></td>
										    <td><span class="numeric"><cfoutput>#rs_taskCommon.task_chooesd#</cfoutput></span></td>
											<td><cfoutput>#rs_taskCommon.tch_name#</cfoutput></td>
											<td><cfif rs_taskCommon.taskClasses eq "-">全校<cfelse><cfoutput>#rs_taskCommon.taskClasses#</cfoutput></cfif></td>
											<td><a title="该教学班不考试" href="<cfoutput>#buildURL('examMidCourseTaskRemoveDo', passArgs)#</cfoutput>" class="stat remove"></a></td>
										</tr>
										</cfloop>
									</cfif>
									<cfif rs_taskOpen.recordCount>
                                        <cfloop query="rs_taskOpen"  >
										<cfset row++ />
										<cfset isArrangeClass ++ />
										<cfset structInsert(passArgs, "TaskID", rs_taskOpen.tsk_id, true) />
										<cfset structInsert(passArgs, "CourseID", courseId, true) />
										<cfset structInsert(passArgs, "TermID", termId, true) />
										<tr class="editRows" rowid="<cfoutput>#rs_taskOpen.tsk_id#</cfoutput>">
											<td><a rowid="<cfoutput>#rs_taskOpen.tsk_id#</cfoutput>" usage="ForTask" class="stat yes"></a></td>
											<td class="index"><cfoutput>#rs_taskOpen.cidx#</cfoutput></td>
											<td>单开班</td>
											<td class="hidden_elem"><span usage="ForTaskClassNames"><cfoutput>#rs_taskOpen.course_name#</cfoutput>-<cfoutput>#rs_taskOpen.tch_name#</cfoutput>-<cfoutput>#rs_taskOpen.cidx#</cfoutput></span></td>
											<td><cfoutput>#rs_taskOpen.campus_name#</cfoutput></td>
											<td><span class="numeric"><cfoutput>#rs_taskOpen.task_week#</cfoutput></span></td>
										    <td><span class="numeric"><cfoutput>#rs_taskOpen.task_chooesd#</cfoutput></span></td>
											<td><cfoutput>#rs_taskOpen.tch_name#</cfoutput></td>
											<td><cfif rs_taskOpen.taskClasses eq "-">全校<cfelse><cfoutput>#rs_taskOpen.taskClasses#</cfoutput></cfif></td>
											<td><a title="该教学班不考试" href="<cfoutput>#buildURL('examMidCourseTaskRemoveDo', passArgs)#</cfoutput>" class="stat remove"></a></td>
										</tr>
										</cfloop>
									</cfif>
								</tbody>
							</table>
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {
									
									$("#opCreate").click(function(){
										
										var $taskSelected = $("a.yes[usage='ForTask']");
										var taskIds = [];
										var taskclassNames = [];
										
										$taskSelected.each(function(){
											
											taskIds.push( $(this).attr("rowid") );
											
											var $tr = $("tr[rowid='" + $(this).attr("rowid") + "']");
											
											taskclassNames.push( $("span[usage='ForTaskClassNames']", $tr).text() );
											
										});
										
										
										if (taskIds.length) {

											$("#TaskClassIDs").val( taskIds.join("|") );
											$("#TaskClassNames").text( taskclassNames.join(", ") );
											
											$("#taskBox").addClass("hidden_elem");
											$("#formBox").removeClass("hidden_elem");
											
										}
										else {
											if(<cfoutput>#isArrangeClass#</cfoutput> > 0){
											   alert("请至少选择一个教学班");
											}else{
											   alert("教学班考试任务已安排，没有可选择的教学班");
											}
											
										}
										
										
									});
									
									
									$("a[usage='ForTask']", $("#taskList")).click(function(){
										
										var rowid = $(this).attr("rowid");
										var status = $(this).hasClass("yes");
										
										var $tr = $("tr[rowid='" + $(this).attr("rowid") + "']");

										/* 切换状态数据 */
										if (status) {
											$(this).removeClass("yes").addClass("no");
										}
										else {
											$(this).removeClass("no").addClass("yes");
										}

									});
									
								});
								// -->
								//]]>				
							</script>
						<cfelse>
							<div class="noticeBlock">
								<h3>课程安排完毕</h3>
								<p><span class="img icon16x16 message"></span>当前学期该门课程的所有考试任务已设置完毕</p>
								<ol>
								</ol>
							</div>
						</cfif>
					</div>
				</div>
				<cfif rs_taskProgramRestore.recordCount or rs_taskCommonRestore.recordCount or rs_taskOpenRestore.recordCount>
					<div id="NoTaskArrange" class="tabContent">
						<div class="noticeBlock">
							<h3>不安排考试教学任务</h3>
							<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 有<em><cfoutput>#arrayLen(taskRestoreArray)#</cfoutput></em>个教学班已标注为不需要安排考试时间</p>
							<hr/>
						</div>
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td width="50">课序号</td>
									<td class="hidden_elem">教学班</td>
									<td width="60">上课校区</td>
									<td width="50">上课周次</td>
									<td width="50">选课人数</td>
									<td width="110">任课教师</td>
									<td>行政班</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
							<cfif rs_taskProgramRestore.recordCount>
                                <cfloop query="rs_taskProgramRestore"  >
									<cfset row++ />
									<cfset structInsert(passArgs, "TaskID", rs_taskProgramRestore.tsk_id, true) />
									<cfset structInsert(passArgs, "CourseID", courseId, true) />
									<cfset structInsert(passArgs, "TermID", termId, true) />
									<tr class="editRows" rowid="<cfoutput>#rs_taskProgramRestore.tsk_id#</cfoutput>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td class="index"><cfoutput>#rs_taskProgramRestore.cidx#</cfoutput></td>
										<td class="hidden_elem"><span usage="ForTaskClassNames"><cfoutput>#rs_taskProgramRestore.course_name#</cfoutput>-<cfoutput>#rs_taskProgramRestore.tch_name#</cfoutput>-<cfoutput>#rs_taskProgramRestore.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_taskProgramRestore.campus_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_taskProgramRestore.task_week#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_taskProgramRestore.task_chooesd#</cfoutput></span></td>
										<td><cfoutput>#rs_taskProgramRestore.tch_name#</cfoutput></td>
										<td><cfif rs_taskProgramRestore.taskClasses eq "-">全校<cfelse><cfoutput>#rs_taskProgramRestore.taskClasses#</cfoutput></cfif></td>
										<td><a title="恢复该教学班课程考试安排" href="<cfoutput>#buildURL('examMidCourseTaskRestoreDo', passArgs)#</cfoutput>" class="stat restore"></a></td>
									</tr> 
								</cfloop>
							</cfif>
							<cfif rs_taskCommonRestore.recordCount>
                                <cfloop query="rs_taskCommonRestore" >
									<cfset row++ />
									<cfset structInsert(passArgs, "TaskID", rs_taskCommonRestore.tsk_id, true) />
									<cfset structInsert(passArgs, "CourseID", courseId, true) />
									<cfset structInsert(passArgs, "TermID", termId, true) />
									<tr class="editRows" rowid="<cfoutput>#rs_taskCommonRestore.tsk_id#</cfoutput>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td class="index"><cfoutput>#rs_taskCommonRestore.cidx#</cfoutput></td>
										<td class="hidden_elem"><span usage="ForTaskClassNames"><cfoutput>#rs_taskCommonRestore.course_name#</cfoutput>-<cfoutput>#rs_taskCommonRestore.tch_name#</cfoutput>-<cfoutput>#rs_taskCommonRestore.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_taskCommonRestore.campus_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_taskCommonRestore.task_week#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_taskCommonRestore.task_chooesd#</cfoutput></span></td>
										<td><cfoutput>#rs_taskCommonRestore.tch_name#</cfoutput></td>
										<td><cfif rs_taskCommonRestore.taskClasses eq "-">全校<cfelse><cfoutput>#rs_taskCommonRestore.taskClasses#</cfoutput></cfif></td>
										<td><a title="恢复该教学班课程考试安排" href="<cfoutput>#buildURL('examMidCourseTaskRestoreDo', passArgs)#</cfoutput>" class="stat restore"></a></td>
									</tr> 
								</cfloop>
							</cfif>
							<cfif rs_taskOpenRestore.recordCount>
                                <cfloop query="rs_taskOpenRestore"  >
									<cfset row++ />
									<cfset structInsert(passArgs, "TaskID", rs_taskOpenRestore.tsk_id, true) />
									<cfset structInsert(passArgs, "CourseID", courseId, true) />
									<cfset structInsert(passArgs, "TermID", termId, true) />
									<tr class="editRows" rowid="<cfoutput>#rs_taskOpenRestore.tsk_id#</cfoutput>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td class="index"><cfoutput>#rs_taskOpenRestore.cidx#</cfoutput></td>
										<td class="hidden_elem"><span usage="ForTaskClassNames"><cfoutput>#rs_taskOpenRestore.course_name#</cfoutput>-<cfoutput>#rs_taskOpenRestore.tch_name#</cfoutput>-<cfoutput>#rs_taskOpenRestore.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_taskOpenRestore.campus_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_taskOpenRestore.task_week#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_taskOpenRestore.task_chooesd#</cfoutput></span></td>
										<td><cfoutput>#rs_taskOpenRestore.tch_name#</cfoutput></td>
										<td><cfif rs_taskOpenRestore.taskClasses eq "-">全校<cfelse><cfoutput>#rs_taskOpenRestore.taskClasses#</cfoutput></cfif></td>
										<td><a title="恢复该教学班课程考试安排" href="<cfoutput>#buildURL('examMidCourseTaskRestoreDo', passArgs)#</cfoutput>" class="stat restore"></a></td>
									</tr> 
								</cfloop>
							</cfif>
							</tbody>
						</table>
					</div>
				</cfif>
				<cfif rs_courseDone.recordCount>
				<div id="DoneArrange" class="tabContent">	
					<div class="noticeBlock">
						<h3>课程考试周次及分组安排</h3>
						<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 有<em><cfoutput>#rs_courseDone.recordCount#</cfoutput></em>场考试安排</p>
						<hr/>
					</div>
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="40">场次</td>
								<td>课程</td>
								<td width="60">考试校区</td>
								<td width="50">考试周</td>
								<td>考试时间</td>
								<td width="18"></td>
							</tr>
						</thead>
						<tbody>
                            <cfloop query="rs_courseDone"  >
								<cfset row++ />
								<cfset structInsert(passDelArgs, "TaskExamID", rs_courseDone.task_exid, true) />
								<cfset structInsert(passDelArgs, "CourseID", courseId, true) />
								<cfset structInsert(passDelArgs, "TermID", termId, true) />
							<tr class="editRows">
								<td class="index"><cfoutput>#rs_courseDone.exidx#</cfoutput></td>
								<td><cfoutput>#rs_courseDone.course_name#</cfoutput></td>
								<td><cfoutput>#rs_courseDone.campus_name#</cfoutput></td>
								<td align="center"><span class="numeric"><cfoutput>#rs_courseDone.wid#</cfoutput></span></td>
								<td><cfif rs_courseDone.wdidx eq "0">-/-<cfelse>星期<span class="numeric"><cfoutput>#rs_courseDone.wdidx#</cfoutput></span>第<span class="numeric"><cfoutput>#rs_courseDone.cellidx#</cfoutput></span>场</cfif></td>
								<td>
									<cfif rs_courseDone.wdidx eq "0">
									<a title="删除考试任务" href="<cfoutput>#buildURL('examMidTaskByDepartmentRemoveDo', passDelArgs)#</cfoutput>" class="stat delete"></a>
									<cfelse>
										<span class="stat locked"></span>
									</cfif>
								</td>
							  </tr>
							</cfloop>
						</tbody>
					</table>
				  </div>
				</cfif>
			</div>
		</li>
	</ul>
</div>